<?php

namespace seecms\wechat;

use seecms\lib\module\ModulePublish;
use seecms\See;

class WechatPublish extends ModulePublish
{

    protected function tableFile(): string
    {
        return dirname(__FILE__, 2) . '/database/table.sql';
    }

    public function seed()
    {
        $this->createMenu();
        $this->createRule();
    }

    protected function getMenuList(): array
    {
        $data = See::db()->table('see_menu')
            ->where('parent_id', 0)
            ->where('title', '常规管理')
            ->find();

        $parent_id = 0;
        if ($data) {
            $parent_id = $data['id'] ?? '';
        }

        return [
            $this->concatMenu($parent_id, '微信公众号', 'layui-icon layui-icon-login-wechat', 'wechat/index'),
        ];
    }

    protected function getRuleList(): array
    {
        return [
            $this->concatRule('wechat', '公众号设置', 'wechat/index'),
            $this->concatRule('wechat', '素材库', 'wechat/materialList'),
            $this->concatRule('wechat', '微信公众号设置', 'wechat/saveConfig'),
            $this->concatRule('wechat', '素材预览', 'wechat/materialPreview'),
            $this->concatRule('wechat', '素材删除', 'wechat/materialRemove'),
            $this->concatRule('wechat', '重置微信公众号菜单', 'wechat/resetMenu'),
            $this->concatRule('wechat', '上传素材', 'wechat/uploadMaterial'),
        ];
    }
}